# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=geoclue
pkgver=2.7.1
pkgrel=1
pkgdesc="dbus geolocation service"
url="https://gitlab.freedesktop.org/geoclue/geoclue/-/wikis/home"
arch="all"
license="LGPL-2.1-or-later"
makedepends="
	avahi-dev
	gobject-introspection-dev
	json-glib-dev
	libnotify-dev
	libsoup3-dev
	meson
	vala
	"
subpackages="$pkgname-dev $pkgname-doc"
install="$pkgname.pre-install"
source="
	https://gitlab.freedesktop.org/geoclue/geoclue/-/archive/$pkgver/geoclue-$pkgver.tar.bz2
	mozilla-location.keys
	"

case "$CARCH" in
	s390x|riscv64)
		_arch_opts="-D3g-source=false -Dcdma-source=false -Dmodem-gps-source=false"
		;;
	*)
		_arch_opts=""
		makedepends="$makedepends modemmanager-dev"
		;;
esac

build() {
	# these keys are for alpine linux use only
	local mozkey
	mozkey="$(base64 -d "$srcdir"/mozilla-location.keys)"
	abuild-meson \
		-Db_lto=true \
		-Ddbus-srv-user=geoclue \
		-Ddbus-sys-dir=/usr/share/dbus-1/system.d \
		-Dgtk-doc=false \
		-Dintrospection=true \
		-Dmozilla-api-key="$mozkey" \
		$_arch_opts \
		build
	meson compile -C build
}

check() {
	meson test --no-rebuild --print-errorlogs -C build
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C build
}

sha512sums="
972663a6f8c969d0e1a5f911af2b8afed486d5c0ba06dadc19bcfbe1ea22cef10243b2bd0084e5c45b70977cfa5650c8f15f760e4bc4e7dbd946745b67c9188b  geoclue-2.7.1.tar.bz2
382510375b1a2fa79be0ab79e3391a021ae2c022429ffbaa7e7a69166f99bb56d01e59a1b10688592a29238f21c9d6977672bd77f9fae439b66bdfe0c55ddb15  mozilla-location.keys
"
